package yt.kpool.activity.salesman;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import butterknife.ButterKnife;
import butterknife.OnClick;
import yt.kpool.R;
import yt.kpool.activity.setting.agent.AgentAc;
import yt.kpool.activity.setting.agent.backwallet.BackWalletAc;
import yt.kpool.activity.setting.agent.myguest.MyGuestActivity;
import yt.kpool.activity.setting.agent.rebatesettlement.RebateSettlementAc;
import yt.kpool.activity.setting.agent.recommendcustomers.RecommendCustomersAc;
import yt.kpool.activity.setting.agent.returnpointquery.ReturnPointQueryActivity;

/**
 * 业务员
 */
public class SalesmanMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_salesman_main);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.ly_my_client, R.id.ly_ReferralClient, R.id.ly_setting, R.id.ly_my_daili, R.id.ll_mysalary})
    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.ly_my_client://我的客户
                startActivity(new Intent(SalesmanMainActivity.this, SalesmanMyGuestActivity.class));
                break;
            case R.id.ly_my_daili://我的代理
                startActivity(new Intent(SalesmanMainActivity.this, MyAgentListActivity.class));
                break;

            case R.id.ly_ReferralClient://推荐客户
                startActivity(new Intent(SalesmanMainActivity.this, RecommendCustomersAc.class));
                break;
                case R.id.ll_mysalary://我的工资
                startActivity(new Intent(SalesmanMainActivity.this, MySalaryActivity.class));
                break;
            case R.id.ly_setting://设置
                startActivity(new Intent(SalesmanMainActivity.this, SalesmanSettingActivity.class));
                break;
        }
    }

    /**
     * 返回键隐藏到后台
     */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            dialog();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    /*退出对话框*/
    public void dialog() {
        final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle("提示")
                .setMessage("确定要退出吗？")
                .setPositiveButton("是", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
//                        Intent intent = new Intent(Intent.ACTION_MAIN);
//                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                        intent.addCategory(Intent.CATEGORY_HOME);
//                        startActivity(intent);
                        finish();
                    }
                })
                .setNegativeButton("否", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        AlertDialog dialog_dialog = dialog.create();
        dialog_dialog.show();
    }
}
